﻿#pragma once

#include "../../MirControls/MirImageControl.h"
#include "../../MirControls/MirButton.h"
#include "../../MirControls/MirLabel.h"
#include "../../../Shared/Data/SharedData.h"
#include "../../MirControls/MirControl.h"
#include <vector>
#include "../../../stringhelper.h"

//C# TO C++ CONVERTER NOTE: Forward class declarations:
namespace Client::MirScenes::Dialogs { class RankingRow; }

using namespace Client::MirControls;
using namespace Client::MirGraphics;
using namespace Client::MirSounds;

namespace Client::MirScenes::Dialogs
{
    class RankingDialog : public MirImageControl
    {
    public:
        MirButton *AllButton, *WarButton, *WizButton, *TaoButton, *SinButton, *ArchButton, *Tab7, *NextButton, *PrevButton;
        MirButton *CloseButton;
        MirLabel *MyRank;

        unsigned char RankType = 0;
        int RowOffset = 0;
        std::vector<RankingRow*> Rows = std::vector<RankingRow*>(20);
        std::vector<std::vector<RankCharacterInfo*>> RankList = std::vector<std::vector<RankCharacterInfo*>>(6);
        std::vector<int> Rank = std::vector<int>(6);

        std::vector<long long> LastRequest = std::vector<long long>(6);


        virtual ~RankingDialog()
        {
            delete AllButton;
            delete WarButton;
            delete WizButton;
            delete TaoButton;
            delete SinButton;
            delete ArchButton;
            delete Tab7;
            delete NextButton;
            delete PrevButton;
            delete CloseButton;
            delete MyRank;
        }

        RankingDialog();

        void Show() override;

        void Hide() override;

        void Toggle();

        void GoToMyRank();

        void Move(int distance);

        void RequestRanks(unsigned char RankType);

        void RecieveRanks(std::vector<RankCharacterInfo*> &Ranking, unsigned char rankType, int MyRank);

        void SelectRank(unsigned char rankType);

        void UpdateRanks();

    public:
        class RankingRow final : public MirControl
        {
        public:
            RankCharacterInfo *Listing;
            MirLabel *RankLabel, *NameLabel, *LevelLabel, *ClassLabel;
            long long Index = 0;

            virtual ~RankingRow()
            {
                delete Listing;
                delete RankLabel;
                delete NameLabel;
                delete LevelLabel;
                delete ClassLabel;
            }

            RankingRow();

            void Inspect();

            void Clear();
            void Update(RankCharacterInfo *listing, int RankIndex);
        };
    };
}
